/*
 * "Copyright (c) 2012 Universitat Pompeu Fabra.
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 *
 * IN NO EVENT SHALL UNIVERSITAT POMPEU FABRA BE LIABLE TO ANY PARTY 
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING 
 * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POMPEU FABRA
 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * UNIVERSITAT POMPEU FABRA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND UNIVERSITAT POMPEU FABRA HAS NO OBLIGATION TO 
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

#define TYPE 80

#include "HbcpNetworkPackets.h"

configuration HbcpAppC {
}
implementation {
	
	//APP
	components MainC;
	components LedsC;
	components new TimerMilliC() as TimerApp;
    components Application;
	
	//NETWORK
	components HbcpForwardingEngineP as Forwarding;
	components HbcpNetworkManagerP as NetworkManager;
	
	components new TimerMilliC() as NMStartForwarding;
	components new TimerMilliC() as NetTimer;
	components new TimerMilliC() as TimeBuffer;
	components new TimerMilliC() as ResetBuffer;
	components new TimerMilliC() as DiscoveryBuffer;
	components new TimerMilliC() as FirstTimeBuffer;
	
	components new QueueC(dataPacket_t*,25) as MessageQueue;
	components new QueueC(uint8_t,25) as SizeQueue;
	components new PoolC(dataPacket_t,25) as DataPool;
	
	//ROUTING
	components HbcpRoutingEngineP as Routing;
    components new TimerMilliC() as TimerGST;
    components new TimerMilliC() as TimerSST;
    components RandomC;
    components new VoltageC() as Battery;
	
	//LINK
	components CC2420ActiveMessageC as ActiveMessageC;
	components new AMSenderC(TYPE);
	components new AMReceiverC(TYPE);	
	components new TimerMilliC() as TimerLink;
	components new VoltageC() as BatteryModule;
	components CC2420PacketC as PacketC;
	components CC2420LinkP as LinkLayer;
	components new TimerMilliC() as AckTimer;

	//APP
   	Application.Boot -> MainC;
  	Application.Leds -> LedsC;
	Application.Network -> Forwarding;
	Application.NetworkInit -> NetworkManager;
	
	//NETWORK MANAGER
	NetworkManager.ForwardingInit -> Forwarding;
	NetworkManager.StartForwarding -> NMStartForwarding;
	NetworkManager.Forwarding -> Forwarding;
	NetworkManager.RoutingEvent -> Routing;
	NetworkManager.Leds -> LedsC;
	NetworkManager.LinkSend -> LinkLayer;
	NetworkManager.Routing -> Routing;
	NetworkManager.AppSignal <- Application;
	NetworkManager.TimeBuffer->TimeBuffer;
	NetworkManager.Random -> RandomC;
	NetworkManager.ResetBuffer -> ResetBuffer;
	NetworkManager.LinkInit -> LinkLayer;
	NetworkManager.RoutingInit -> Routing;
	NetworkManager.DiscoveryBuffer -> DiscoveryBuffer;
	NetworkManager.FirstTimeBuffer -> FirstTimeBuffer;
	
	//FORWARDING
	Forwarding.LinkSend -> LinkLayer;
	Forwarding.CC2420Packet -> PacketC;
	Forwarding.Packet->ActiveMessageC;
	Forwarding.RoutingEvent<-Routing;
    Forwarding.LinkReceive->LinkLayer;
    Forwarding.Routing->Routing;
    Forwarding.DataQueue->MessageQueue;
    Forwarding.SizeQueue->SizeQueue;
    Forwarding.DataPool->DataPool;
	
	//ROUTING
    Routing.Packet->PacketC;
    Routing.TimerGST->TimerGST;
    Routing.Random->RandomC;
    Routing.BatteryReader->Battery;
    Routing.Leds -> LedsC;
	
 	//LINK
	LinkLayer.SplitControl -> ActiveMessageC;
	LinkLayer.Receive ->AMReceiverC ;
	LinkLayer.RadioAMSend -> AMSenderC;
	LinkLayer.Packet -> AMSenderC;
	LinkLayer.PacketAcknowledgements -> ActiveMessageC;
	LinkLayer.AMPacket -> ActiveMessageC;
	LinkLayer.CC2420Packet->ActiveMessageC;
	LinkLayer.PacketLink->ActiveMessageC;
	LinkLayer.Random->RandomC;
	LinkLayer.SeedInit->RandomC;

}